﻿#region

using System.Collections.Generic;
using System.Configuration;
using BTL.Technology.Framework.Configuration;

#endregion

namespace BTL.Technology.Data
{
    public abstract class DatabaseConfiguration : ISectionConfiguration
    {
        private readonly Dictionary<string, string> _sectionCollection;


        private string _connectionString;

        protected DatabaseConfiguration()
        {
            _sectionCollection = new Dictionary<string, string>();
        }

        public abstract string ConnectionName { get; }

        public string ConnectionString
        {
            get
            {
                if (string.IsNullOrEmpty(_connectionString))
                {
                    _connectionString = ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString;
                }
                return _connectionString;
            }
            protected set { _connectionString = value; }
        }

        #region ISectionConfiguration Members

        public void Add(string sectionName, string sectionValue, List<KeyValuePair<string, string>> valuePairs)
        {
            _sectionCollection.Add(sectionName, sectionValue);
        }

        #endregion
    }
}